﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LuatChoi;
using System.Drawing;

namespace Client
{
    static class PicBox
    {
        public static void VeDanhSachQuan(this PictureBox pictureBox, List<QuanCo> ls)
        {
            var p = new Point(3, 3);
            var g = pictureBox.CreateGraphics();
            foreach (QuanCo quan in ls)
            {
                try
                {
                    g.DrawImage(LayAnh(quan), p);
                    if (p.X > pictureBox.Width - 40)
                    {
                        p.X = 3;
                        p.Y = p.Y + 30;
                    }
                    else
                    {
                        p.X += 20;
                    }
                }
                catch
                {
                }

            }
        }

        static Bitmap LayAnh(QuanCo quan)
        {
            if (quan is Tot)
                return Properties.Resources.q1;
            if (quan is Ma)
                return Properties.Resources.q2;
            if (quan is Tuong)
                return Properties.Resources.q3;
            if (quan is Xe)
                return Properties.Resources.q4;
            if (quan is Hau)
                return Properties.Resources.q5;
            return null;
        }
    }
}
